<template>
	<div class="main-box card filter main-box-part">
		<el-tabs v-model="activeName" class="tabs">
			<el-tab-pane label="上传设置" name="upload">
				<div class="content">
					<div class="content-part"><Upload ref="upload" @submitForm="() => submitForm()" /></div>
					<div class="content-part"></div>
				</div>
			</el-tab-pane>
		</el-tabs>
	</div>
</template>
<script setup lang="ts" name="">
import { ref } from "vue";

import { ElMessage } from "element-plus";

import Upload from "./components/Upload/index.vue";

import { settingsGet, settingSet } from "@/api/modules/develop";

const upload = ref<InstanceType<typeof Upload>>();

settingsGet({ field: ["upload_slice_size", "upload_max_size", "upload_file_type", "upload_check_file_type","oss_start", "oss_access_key_id", "oss_access_key_secret", "oss_endpoint", "oss_bucket" , "oss_role_arr"] }).then(res => {
	upload.value?.initData(res.data);
});

const activeName = ref("upload");
// const sms = ref<InstanceType<typeof Sms>>();
// const userAgreement = ref<InstanceType<typeof Agreement>>();
// const privacyAgreement = ref<InstanceType<typeof Agreement>>();
// watch(
// 	activeName,
// 	async () => {
// 		const {
// 			send_sms_access_key_id,
// 			user_agreement,
// 			privacy_agreement,
// 			send_sms_access_key_secret,
// 			send_sms_sign_name,
// 			send_sms_mod_code
// 		} = (
// 			await getItem([
// 				"send_sms_access_key_id",
// 				"user_agreement",
// 				"privacy_agreement",
// 				"send_sms_access_key_secret",
// 				"send_sms_sign_name",
// 				"send_sms_mod_code"
// 			])
// 		).data;

// 		sms.value?.initData({ send_sms_access_key_id, send_sms_access_key_secret, send_sms_sign_name, send_sms_mod_code });
// 		userAgreement.value?.initData(user_agreement);
// 		privacyAgreement.value?.initData(privacy_agreement);
// 	},
// 	{ immediate: true }
// );
const submitForm = async () => {
	if (!upload.value?.ruleForm) return;
	await settingSet({ ...upload.value?.ruleForm });
	ElMessage.success("设置成功");
};
</script>
<style scoped lang="scss">
@import "./index.scss";
</style>
